package com.xcity.game.battle.pve.employee;

import java.util.Random;

import com.xcity.game.battle.BattleException;
import com.xcity.game.battle.pve.PlayerBattler;
import com.xcity.game.common.ICalculator;
import com.xcity.game.employee.skill.EmployeeSkill;

import naga.x.game.time.TimeUpdater;

/**
 * 每场战斗的员工技能环境
 * @author yang.li
 *
 */
public abstract class EmployeeSkillBattleContext implements ICalculator {

	protected PlayerBattler player;
	protected EmployeeSkill ref;
	protected long lastTriggerTime; // 该技能上次触发时间
	protected int triggeredTimes; // 该技能在本次战斗中累计触发次数
	protected Random rnd = new Random();
	
	public EmployeeSkillBattleContext(PlayerBattler player, EmployeeSkill ref) {
		this.player = player;
		this.ref = ref;
	}
	
	public boolean isInCD() {
		int cd = ref.getTemplate().getCd();
		if (cd <= 0) {
			return false;
		}
		return lastTriggerTime != 0 && lastTriggerTime + cd * 1000 < TimeUpdater.getInstance().now();
	}
	
	public EmployeeSkill getSkill() {
		return ref;
	}
	
	@Override
	public <T> T calc(int id, Object... vals) {
		return null;
	}

	public abstract boolean trigger() throws BattleException;
	
}
